﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace Sai_Se_Dung
{
    public partial class About : PhoneApplicationPage
    {
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            PlayBackgroundSound();
        }

        private void PlayBackgroundSound()
        {
            if (Option.isOn == true)
            {
                mp3_about.AutoPlay = true;
                mp3_about.Play();
            }
            else
            {
                mp3_about.AutoPlay = false;
                mp3_about.Stop();
            }
        }

        public About()
        {
            InitializeComponent();
        }

        
        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            if (Option.isOn == true)
            {
                mp3_btn.Play();
            }

            if (NavigationService.CanGoBack)
            {
                while (NavigationService.RemoveBackEntry() != null)
                {
                    NavigationService.RemoveBackEntry();
                }
            }
            NavigationService.Navigate(new Uri("/Menu.xaml", UriKind.Relative));
        }

        private void mp3_about_MediaEnded(object sender, RoutedEventArgs e)
        {
            PlayBackgroundSound();
        }
    }
}